#!/usr/bin/perl -w
use strict;
use warnings;

require('function.pl');

load_proxies();
open IN, "data/phone_num_email" or die("fail\topen data/phone_num_email\n");
open OUT, ">>data/email";
while (<IN>) {
	chomp;
	next if (length != 11 || $_ % $ARGV[0] != $ARGV[1]);
	my $url = 'http://www.google.ca/search?newwindow=1&site=&source=hp&q='.$_.'+email&btnK=Google+%E6%90%9C%E7%B4%A2';
	$url = 'http://www.google.com.hk/search?hl=zh&source=hp&q='.$_.'+email&btnG=Google+%E6%90%9C%E7%B4%A2&sei=d4eDUePdFs-HkgXi84CwDQ&gbv=2';
#	my $content = fetch_url_via_proxy('http://www.google.ca/search?newwindow=1&site=&source=hp&q='.$_.'+email&btnK=Google+%E6%90%9C%E7%B4%A2');
	my $content = `curl -A fuck_google -s '$url'`;
	print $content;
#	while ($content =~ /^([0-9a-zA-Z]{3,}|[0-9a-zA-Z]+(-|_)?[0-9a-zA-Z_-]+\.?[0-9a-zA-Z]+)\@[0-9a-zA-Z]+\.[0-9a-zA-Z]+(\.\w+)?/) {
	my $emails = '';
	while ($content =~ /(\w+@[\w\-\.]+)/g) {
		$emails .= "\t$1";
	}
	print "$_$emails\n" if (1 || $emails);
}
close IN;
close OUT;
